package com.syaccp.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.syaccp.mapper.TMessageMapper;
import com.syaccp.model.TMessage;
import com.syaccp.service.TMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.syaccp.vo.TMessageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author syaccp
 * @since 2023-07-15
 */
@Service
public class TMessageServiceImpl extends ServiceImpl<TMessageMapper, TMessage> implements TMessageService {

    @Autowired
    private TMessageMapper mapper;
    @Override
    public PageInfo<TMessageVo> getMessagePageByReceiverId(Integer index, TMessageVo tMessageVo) throws SQLException {
        PageHelper.startPage(index,5);
        return new PageInfo<TMessageVo>(mapper.getMessageByReceiverId(tMessageVo));
    }

    @Override
    public boolean delMessage(Integer id) throws SQLException {
        return mapper.delMessage(id);
    }

    @Override
    public boolean delMessageReceiver(Integer message_id,Integer receiver_id) throws SQLException {
        return mapper.delMessageReceiver(message_id,receiver_id);
    }

    @Override
    public PageInfo<TMessageVo> getNotRead(Integer index, TMessageVo tMessageVo) throws SQLException {
        PageHelper.startPage(index,5);
        return new PageInfo<TMessageVo>(mapper.getNotRead(tMessageVo));
    }

    @Override
    public boolean updateIsRead(TMessageVo tMessageVo) throws SQLException {
        return mapper.updateIsRead(tMessageVo);
    }

    @Override
    public List<TMessageVo> selectNotReadMessage(TMessageVo tMessageVo) throws SQLException {
        return mapper.selectNotReadMessage(tMessageVo);
    }

    @Override
    public boolean allRead(TMessageVo tMessageVo) throws SQLException {
        return mapper.allRead(tMessageVo);
    }

    @Override
    public int insert(TMessageVo tMessageVo) {
        return mapper.insert(tMessageVo);
    }

    @Override
    public int insertMessageReceiver(TMessageVo tMessageVo) throws SQLException {
        return mapper.insertMessageReceiver(tMessageVo);
    }


}
